package com.Brewing.springboot;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import com.Brewing.springboot.controller.interceptor.MiniInterceptor;


/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Company: </p>
 * @author  庄磊
 * @date	2018年12月6日 下午3:39:50 
 * @version 1.0
 */
@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport  {

	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		// TODO Auto-generated method stub
		//本地
		registry.addResourceHandler("/**")
		.addResourceLocations("classpath:/META-INF/resources/")
				.addResourceLocations("file:C:/Brewing-videos-dev/");
		//服务器
//		registry.addResourceHandler("/**")
//		.addResourceLocations("classpath:/META-INF/resources/")
//				.addResourceLocations("file:/usr/local/Brewing-videos-dev/");
	}
	@Bean(initMethod="init")
	public ZKCuratorClient zkCuratorClient() {
		return new ZKCuratorClient();
	}
	@Bean
	public MiniInterceptor miniInterceptor() {
		return new MiniInterceptor();
	}
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		
		registry.addInterceptor(miniInterceptor()).addPathPatterns("/user/**")
				       .addPathPatterns("/video/upload",
				    		   			"/video/userLike", "/video/userUnLike",
				    		   			"/video/saveComment")
												  .excludePathPatterns("/user/queryPublisher");
		
		super.addInterceptors(registry);
	}

	
}
